<?php
/**
 * Short Description  
 *
 * Long Description 
 *
 * @category   
 * @package    
 * @subpackage 
 * @copyright 
 * @author     Sandeep Manne<sandeep.manne@costrategix.com>
 */

require_once "Core/System/Linux.php";

class Core_System_Debian extends Core_System_Linux
{
	/**
	 * Dont use this method, its not yet tested
	 * 
	 * @param string $extension
	 * @return array|string
	 */
	public static function installPhpExtension($extension)
	{
		exec("aptitude search php5-".$extension, $output);
		if (count($output) === 0) {
			throw new Core_System_Exception("Extension not found");
		} else if (count($output) > 1) {
			throw new Core_System_Exception("Too many extensions found");
		} else {
			$output = $output[0];
		}
		
		$asArray = explode(" ",$output);
		
		if ($asArray[0] == 'i') {
			throw new Core_System_Exception("Extension already installed");
		} else if ($asArray[0] == 'p' || $asArray[0] == 'pi') {
			self::run("aptitude -q -y install php5-".$extension, $output);
		}
		return $output;
	}
}